<?php 
	echo $html->css( 'jquery-ui-1.8.16.custom.css' );
	echo $html->css( 'visualize.css' );
	echo $html->css( 'visualize-dark.css' );
	$javascript->link( array( 'jquery/jquery-1-6-4', 'jquery/jquery-ui-1.8.16.custom.min', 'jquery/charting/js/visualize.jQuery' ), false );
?>
<script>
	$(document).ready( function() {
		$("#daysTable").visualize();
		
		$("#endDate").visualize({
			'type'  : 'area'
		});
		
		$("#projects").visualize({
			'type'  : 'pie',
			pieMargin: 5
		});
	});
</script>

<style>
	span.label{
		writing-mode: tb-rl; 
		filter: flipv fliph;
	}
</style>

<div id="actions">
	<?php 
		echo $html->link( 'Mi Agenda', array( 'controller' => 'schedules', 'index' ) );
		echo $html->link( 'Mis Proyectos', array( 'controller' => 'projects', 'index' ) );
	?>
</div>

<div class="tableChart floatL">
	<table style="display:none;" id="daysTable" >
		<caption>Horas Dedicadas a Tareas por Dia</caption>
		<thead>
			<tr>
				<td></td>
				<th scope="col"></th>
			</tr>
		</thead>
		<tbody>
			<?php foreach($listTasks  as $listTask ) : ?>
				<tr>
					<th scope="row">
						<?php 
							switch( date( 'l', strtotime( $listTask['Task']['start_date'] ) )  ){
								case 'Friday':
									echo 'Viernes';
									break;
								case 'Monday':
									echo 'Lunes';
									break;
								case 'Tuesday':
									echo 'Martes';
									break;
								case 'Wednesday':
									echo 'Miercoles';
									break;
								case 'Thursday':
									echo 'Jueves';
									break;
								case 'Saturday':
									echo 'Sabado';
									break;
								case 'Sunday':
									echo 'Domingo';
									break;
							}
						?>
					</th>
					<td><?php echo $listTask[0]['hours'] ?></td>
				</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
</div>


<div class="tableChart floatR">	
	<table style="display:none;" id="projects" >
		<caption>Consumo de Tiempo por Proyectos</caption>
		<thead>
			<tr>
				<td></td>
				<th scope="col"></th>
			</tr>
				
		</thead>
		<tbody>
			<?php foreach($listProjects  as $listProject ) : ?>			
				<tr>
					<th scope="row"><?php echo $listProject['Project']['name'] ?></th>
					<td>
						<?php 
							$intHours = 0;
							foreach( $listProject['Category'] as $listCategory ){
								foreach( $listCategory['Task'] as $listTask )
									$intHours += $listTask['estimated_hours'];
							}
							echo $intHours;
						?>
					</td>
				</tr>
			<?php endforeach; ?>
		
		</tbody>
	</table>
</div>

<div class="clear"></div>

<div class="tableChart floatL">	
	<table style="display:none;" id="endDate" >
		<caption>Entrega de Tareas</caption>
		<thead>
			<tr>
				<td></td>
				<?php foreach( $listPendingTasks as $listTask ) : ?>
						<th scope="col"><?php echo date( 'Y-m-j', strtotime( $listTask['Task']['end_date'] ) ) ?></th>
				<?php endforeach; ?>
			
				<?php foreach( $listCompletedTasks as $listTask ) : ?>
					<th scope="col"><?php echo date( 'Y-m-j', strtotime( $listTask['Task']['end_date'] ) ) ?></th>
				<?php endforeach; ?>

			</tr>
		</thead>
		<tbody>
			
			<tr>
				<th scope="row">Tareas Pendientes</th>
					<?php foreach($listPendingTasks  as $listTask ) : ?>
						<td><?php echo $listTask[0]['count'] ?></td>
					<?php endforeach; ?>
			</tr>
			
			
			<tr>
				<th scope="row">Tareas Completadas</th>
					<?php foreach($listCompletedTasks  as $listTask ) : ?>
						<td><?php echo $listTask[0]['count'] ?></td>
					<?php endforeach; ?>
			</tr>
			
		</tbody>
	</table>
</div>

<div class="clear"></div>
